package model

import (
	"newRetailByGolang/variable"
	"time"
)

type User struct {
	Id int64 `gorm:"primaryKey"`
	Name string
	VipLevel int
	VipLevelName string
	AgentLevel int
	AgentLevelName string
	BoundStoreId int64
	BoundStoreName string
	RecommendedUserId int64
	RecommendedUserName string
	Integral string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (user *User) FindUserById(id int64) *User {
	var u *User
	variable.Db.Where("id = ?", id).First(&u)
	return u
}

func (user *User) FindSubordinates(id int64) []*User {
	var userList []*User
	variable.Db.Where("recommended_user_id = ?", id).Find(&userList)
	return userList
}
